package com.atguigu.oshiapp.oshiapp.common;

import lombok.Data;

/**
 * @Author: Mouoal
 * @CreateTime: 2025-01-06  23:31
 * @Version: 1.0
 */
@Data
public class R {
    private Integer code;
    private String msg;
    private Object data;


    public R(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public R(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static R ok() {
        return new R(200, "操作成功");
    }

    public static R ok(Object data) {
        return new R(200, "操作成功", data);
    }

    public static R ok(String msg) {
        return new R(200, msg);
    }
    public static R ok(Integer code, String msg) {
        return new R(code, msg);
    }
    public static R ok(String code, String msg) {
        return new R(200, msg);
    }

    public static R error() {
        return new R(500, "error操作失败");
    }

    public static R error(String msg) {
        return new R(500, msg);

    }

    public static R error(Integer code, String msg) {
        return new R(code, msg);
    }

    public static R error(Object data) {
        return new R(500, "操作失败", data);
    }
}
